﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;
using sysIO = System.IO;
using System.IO;
using COFE.Core.Lister;
using COFE.Core.Profile;
using NUnit.Framework;

namespace COFE.Core.Entry
{
    /// <summary>
    /// Represent a file, please use COFE.Core.IFileInfo interface instead.
    /// </summary>
    public class FileInfoExA : FileSystemInfoExA, IInternalFileInfoExA
    {
        #region Constructors

        public FileInfoExA(string listerKey, IPropertyProvider primaryPropProvider)
            : base(listerKey, primaryPropProvider)
        {
            
        }

        #endregion

        #region Methods

        public void UpdateSource()
        {            
            if (!this.IsFileSystem)
            {
                IInternalDirectoryInfoExA iParent = this.Parent as IInternalDirectoryInfoExA;
                Assert.IsNotNull(iParent);
                IInternalFileInfoExA tempFile = COFEShared.PathParser.TryParsePath(this.TempPath, ParsableType.ParsePath) as IInternalFileInfoExA;
                Assert.IsNotNull(tempFile);
                iParent.DirectoryController.Copy(tempFile, iParent, false);
            }
        }

        public void MoveTo(string destFileName)
        {
            throw new NotImplementedException();
        }


        #endregion

        #region Data

        #endregion


        #region Public Properties

        public new IInternalFileInfoExA InternalProperties { get { return this as IInternalFileInfoExA; } }

        public IStreamProvider StreamProvider { get { return getVolume().StreamProvider; } }

        #region PropertyProvider's Properties

        public string Extension { get { return COFEPath.GetExtension(Name); } }
        public long Length{ get { return GetProperty(FileInfoProperties.Length).ValueAsInt64; } }        
        public string CRC{ get { return GetProperty(FileInfoProperties.CRC).ValueAsString; } }
        
        #endregion

        

        #endregion


    }
}
